<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        // Starts a session
        session_start();
        
        // Includes the connection to the Database
        include 'dbConfig.php';
        
        // Select Query
        $q = "SELECT * FROM users"
                ." WHERE Email='" . $_POST["email"] . "' "
                ." AND Password='" . md5($_POST["password"]) . "' ";
        
        // Run the Query
        $r = mysql_query($q);
        
        if ( $obj = mysql_fetch_object($r) ) {
            // Create session variables
            $_SESSION["valid_id"] = $obj->ID;
            $_SESSION["valid_email"] = $_POST["email"];
            $_SESSION["valid_time"] = time();
            $_SESSION["valid_username"] = $obj->Name;
            $_SESSION["valid_admin"] = $obj->Admin;
			$_SESSION["content_stockcharts"] = $obj->content_stockcharts;
			$_SESSION["content_finance"] = $obj->content_finance;
            
            // Close mysql
            mysql_close($ms);
            
            // Redirect to overview page
            header("Location: overview.php");
        }
        else
        {
            // Close mysql
            mysql_close($ms);
            
            //Login not successful
            $_SESSION["wronglogin"] = 1;
            header("location:index.php");
        }
        ?>
    </body>
</html>